/*
 * @Author: HZK
 * @Date: 2020-09-15 16:11:59
 * @LastEditTime: 2020-09-16 10:28:43
 * @LastEditors: hanfengmi
 * @Description: 
 */
const Generator = require('yeoman-generator');

module.exports = class extends Generator {
    promptting () {
        return this.prompt([
            {
                type: 'input',
                name: 'name',
                message: 'Your Project Name?',
                default: this.appname
            },
            {
                type: 'input',
                name: 'port',
                message: 'Your Project Port?',
                default: 8080
            }
        ]).then(answes=>{
            this.answes = answes
        })
    }
    writting(){
        const templates = [
            'webpack.config.js',
            'package.json',
            '.umirc.js',
            '.prettierrc',
            '.prettierignore',
            '.gitignore',
            '.eslintrc',
            '.env',
            '.editorconfig',
            'mock/user.js',
            'src/global.css',
            'src/app.js',
            'src/utils/index.js',
            'src/service/config.js',
            'src/service/request.js',
            'src/service/home.js',
            'src/pages/index.js',
            'src/pages/index.less',
            'src/pages/document.ejs',
            'src/models/home.js',
            'src/layouts/index.js',
            'src/layouts/index.css',
            'src/components/Part/index.js',
            'src/components/Part/index.less',
            'src/components/Footer/index.js',
            'src/components/Footer/index.less',
            'src/components/Header/index.js',
            'src/components/Header/index.less',
            'src/assets/banner.jpg',
            'src/assets/bg.png',
            'src/assets/yay.jpg',
        ]
        templates.forEach(item =>{
            this.fs.copyTpl(
                this.templatePath(item),
                this.destinationPath(item),
                this.answes
            )
        })
    }
}
